home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Linux Cubed Series 7: Sunsite
/
Linux Cubed Series 7 - Sunsite Vol 1.iso
/
system
/
shells
/
kiss-0.11
/
kiss-0
/
kiss
/
src
/
docat.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-03-23
|
934b
|
50 lines
#include "kiss.h"
int docat (Stringstack s)
{
register int
showall = 0,
printonly = 0,
i,
ret = 0,
opt;
FILE
*inf;
while ( (opt = getopt (s.nstr, s.str, "hsp")) != -1 )
switch (opt)
{
case 'p':
printonly++;
break;
case 's':
showall++;
break;
case 'h':
default:
error ("Bad commandline.\n"
"Usage: %s [-hps] [file(s)]\n"
"Where:\n"
" -h: this message\n"
" -p: show only printable chars\n"
" -s: show filenames while cat-ting\n"
" file(s): files to copy to stdout\n",
progname);
}
if (optind >= s.nstr)
catfile (stdin, "stdin", showall, printonly);
else for (i = optind; i < s.nstr; i++)
{
if (! (inf = fopen (s.str [i], "r")) )
ret += warning ("cannot open \"%s\"", s.str [i]);
else
{
catfile (inf, s.str [i], showall, printonly);
fclose (inf);
}
}
return (ret);
}